package com.demo.Test;

import net.sf.json.JSONObject;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class UserRegistration {

	public static void main(String[] args) {
		String info = null;
	//	String ssss="versionId=3&merchantId=00000000000118&orderId=RC150331914334&settleDate=2015-03-31&completeDate=2015-03-31&status=1&notifyTyp=0&payOrdNo=15033100000219&orderAmt=100&signType=MD5Kwkc0bfJ4A1d";
	//	String sss="00000000000118&RC150331914334&20150331&1&0&15033100000219&100&MD5&Kwkc0bfJ4A1d";
		try {
	//		System.out.println("ssss=="+TdRaAndCaUtil.HKMD5(sss));
			HttpClient httpclient = new HttpClient();
			PostMethod post = new PostMethod("http://211.162.68.169/user/UserRegistration.tran");//
			post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
			post.addParameter("MERNO", "00000000000094");
			post.addParameter("USRMP", "18512699272");
			post.addParameter("USERNAME", "和香菱");
			String pass = TdRaAndCaUtil.HKMD5("admin123");// 0192023a7bbd73250516f069df18b500
			post.addParameter("PASS", pass);
			post.addParameter("IDTYPECODE", "0");
			post.addParameter("USERNO", "411424198411172445");
			post.addParameter("CEMAIL", "hxl2014@40qq.com");
			String passzf = TdRaAndCaUtil.HKMD5("hxl2014");// 08c8ad4226b4e4312c8e5563a3d0149
			post.addParameter("PAYPASS", passzf);
			post.addParameter("PACTNO", "1234");
			String str = "MERNO=00000000000094&USRMP=18512699272&USERNAME=和香菱&PASS=0192023a7bbd73250516f069df18b500&nqkHwgkRdWy5";
			System.out.println("发送--加密前参数==" + str);
			post.addParameter("SIGNDATA",  TdRaAndCaUtil.HKMD5(str));
			System.out.println("发送--加密后参数==" + TdRaAndCaUtil.HKMD5(str));
			int httpcode = httpclient.executeMethod(post);
			System.out.println("httpcode---->" + httpcode);
			info = new String(post.getResponseBody(), "UTF-8");
			System.out.println("返回信息---->" + info);
			JSONObject jsonObj = JSONObject.fromString(info);
			String MERNO = jsonObj.getString("MERNO");
			String CUSTNO = jsonObj.getString("CUSTNO");
			String PAYACNNO = jsonObj.getString("PAYACNNO");
			String SIGNDATA = jsonObj.getString("SIGNDATA");
			String RSPCOD = jsonObj.getString("RSPCOD");
			String RSPMSG = jsonObj.getString("RSPMSG");
			System.out.println("RSPCOD==" + RSPCOD);
			System.out.println("返回加密参数==" + SIGNDATA);
			String str2 = "MERNO=" + MERNO + "&CUSTNO=" + CUSTNO + "&PAYACNNO="+ PAYACNNO + "&nqkHwgkRdWy5";
			System.out.println("接收--加密前参数==" + str2);
			System.out.println("接收--加密后参数==" + TdRaAndCaUtil.HKMD5(str2));
			if (TdRaAndCaUtil.HKMD5(str2).equals(SIGNDATA)) {
				System.out.println("注册成功");
			} else {
				System.out.println("注册失败");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
